home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6439 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.3 KB

  1. Path: kettle.magna.com.au!news
  2. From: peter@magna.com.au (Peter J Brock)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: STL container classes and destroy()
  5. Date: Fri, 09 Feb 1996 06:39:25 GMT
  6. Organization: Me
  7. Message-ID: <4fcn8h$7pq@kettle.magna.com.au>
  8. References: <Pine.BSF.3.91.960204202036.7806A-100000@cyb.gridpoint.com>
  9. Reply-To: peter@magna.com.au
  10. NNTP-Posting-Host: enterprise.magna.com.au
  11. X-Newsreader: Forte Free Agent v0.55
  12.  
  13. "Bruce J. Keeler" <loodvrij@cyb.gridpoint.com> wrote:
  14.  
  15. >Hi.  I have a question about the STL container classes and their use with
  16. >user-defined types.  The test program below fails to compile as shown.
  17. >If I use vector<asdf *> it compiles but gives a warning similar to the message
  18. >shown.  
  19.  
  20. >In the stl defalloc.h file I notice a whole bunch of versions of
  21. >destroy(foo) one for each built-in type.  Are we expected to include similar
  22. >definitions in the header files for our classes?  Doing so certainly seems
  23. >to get rid of the messages, but it still seems kinda klunky and possibly
  24. >just darn wrong to me.
  25.  
  26. >Compiler is the AIX xlC compiler, version (I think) 1.1.2.
  27.  
  28. >Thanks.
  29. >---------------------------------------8<---------------------------------
  30. >#include <vector.h>
  31.  
  32. >class asdf
  33. >{
  34. >    asdf() {}
  35. >    ~asdf() {}
  36. >    int spam;
  37. >};
  38.  
  39. >class Blah
  40. >{
  41. >    vector<asdf> asdfList;
  42. >};
  43.  
  44. >int main (int, char **)
  45. >{
  46. >    Blah blah; 
  47. >}
  48.  
  49. >xlC -+ -U__STR__ -Istl -g
  50. >-DMOD_SYM=3Dctgnd -DMODULE_NAME=3D"ctgnd" -c vector-test.cc
  51. >"stl/defalloc.h", line 74.1: 1540-013: (S) "~T" is undefined.
  52. >"stl/defalloc.h", line 73.1: 1540-207: (I) The previous message applies 
  53. >to the definition of template "destroy(asdf*)".
  54.  
  55.  
  56.  
  57.  
  58.  
  59. >Bruce J. Keeler                               Internet: loodvrij@gridpoint.com
  60. >-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  61. >"Never trust an Operating System you don't have source code for."
  62.  
  63. I tried your code under my compiler. Microsoft Visual C++ 4.0 using
  64. two different versions of STL.
  65.  
  66. 1) HP implementation that ships with MS VC++ 4.0, gives
  67. ---------Configuration: test - Win32 Debug--------------------
  68. Compiling...
  69. test1.cpp
  70. E:\DEVAPPS\stl\hp\STL\iterator.h(65) : warning C4114: same type
  71. qualifier used more than once
  72. E:\DEVAPPS\stl\hp\STL\iterator.h(65) : warning C4114: same type
  73. qualifier used more than once
  74. Linking...
  75. test.exe - 0 error(s), 2 warning(s)
  76.  
  77. 2) ObjectSpace STL<ToolKit>, gives
  78. ---------Configuration: test - Win32 Debug--------------------
  79. Compiling...
  80. test1.cpp
  81. D:\deriv\TOOLS\OSPACE\ospace\stl\basalgo.cc(412) : error C2678: binary
  82. '<' : no operator defined which takes a left-hand operand of type
  83. 'const class asdf' (or there is no acceptable conversion) (new
  84. behavior; please see help)
  85. D:\deriv\TOOLS\OSPACE\ospace\stl\basalgo.cc(415) : error C2678: binary
  86. '<' : no operator defined which takes a left-hand operand of type
  87. 'const class asdf' (or there is no acceptable conversion) (new
  88. behavior; please see help)
  89. Error executing cl.exe.
  90. test.exe - 2 error(s), 0 warning(s)
  91.  
  92. Niether gave me the error message that you had.
  93.  
  94. I guess the problem could lay with the compiler, since I'm
  95. assuming you are using the HP STL.
  96.  
  97. Appart from that, the only suggestion I can make is from the
  98. FAQ. Provide the BIG THREE,
  99. Destructor, copy constructor, and assignment operator.
  100.  
  101.  
  102. Cheers,
  103. Peter J Brock
  104. http://www.magna.com.au/~peter
  105.  
  106.